#include <iostream>

#include "libav.hpp"

int main(int argc, char** argv) {
  std::string src;
  if (argc < 2)
    src = "https://www.radiantmediaplayer.com/media/bbb-360p.mp4";
  else
    src = argv[1];

  LibAV t;
  t.init(src);
  std::this_thread::sleep_for(std::chrono::seconds(1));
  // cv::VideoCapture cap(src);
  cv::Mat image;
  while (1) {
    // cap >> image;
    image = t.getMat();
    if (!image.empty())
      cv::imshow("press ESC to exit", image);
    else {
      std::cerr << "[Error] Image not retrived" << std::endl;
      continue;
    }
    if (cv::waitKey(30) == 0x1b) break;
  }
  return 0;
}
